<template>
  <div style="border: 1px solid rgb(235, 237, 240)" :title="$t('all.autotext272')" @back="() => $router.go(-1)">
    <a-card>
      <a-form-model layout="inline" ref="formRef">
        <!-- 基本信息 -->
        <a-row :gutter="[24, 12]">
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext10') + ':'" labelAlign="left">
              <span>{{ $store.getters.userInfo.userName }}</span>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext1091')" labelAlign="left">
              <span>{{ date }}</span>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext1005')" labelAlign="left">
              <span>{{ totalAmt }}</span>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext149')" labelAlign="left">
              <span>{{ $route.query.pname }}</span>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext455')" labelAlign="left" :required="true">
              <a-select
                :default-value="$t('all.autotext1348')"
                style="width: 183px"
                show-search
                :filter-option="filterOption"
                @change="handleCenterChange"
                v-model="centerName"
              >
                <a-select-option v-for="item in centerList" :key="item.id" :value="item.id">
                  <span :title="item.researchCenterNo + '-' + item.orgName">
                    {{ item.researchCenterNo }}-{{ item.orgName }}
                  </span>
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext1157')" labelAlign="left" :required="true">
              <a-select
                :default-value="$t('all.autotext1348')"
                style="width: 183px"
                @change="handlePersonChange"
                show-search
                :filter-option="filterOption"
                v-model="personName"
              >
                <a-select-option v-for="item in personList" :key="item.researchNo" :value="item.researchNo">
                  <span :title="'PI -' + item.account">
                    PI-{{ item.account }}
                  </span>
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext473')" labelAlign="left" :required="true">
              <a-select
                :default-value="$t('all.autotext1348')"
                style="width: 183px"
                @change="handleAccountChange"
                v-model="accountId"
              >
                <a-select-option v-for="item in accountList" :key="item.id" :value="item.id">
                  <span :title="`${$options.filters.enumValueByKey(item.bankType, $const.BANK_TYPE)} ${item.bankCardNo}`">
                    {{ item.bankType | enumValueByKey($const.BANK_TYPE) }} {{ item.bankCardNo }}
                  </span>
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col class="gutter-row" :span="8">
            <a-form-model-item :label="$t('all.autotext74')" labelAlign="left">
              <span>{{ moneyType }}</span>
            </a-form-model-item>
          </a-col>
          <!-- <a-col class="gutter-row" :span="24" v-if="OriginFeeApplyInfo.length">
            <a-form-model-item :label="$t('all.autotext1745')" labelAlign="left" :required="true">
              <div :key="i" v-for="(item, i) in OriginFeeApplyInfo">
                <a  style="margin-right:10px;" @click="handleOrigin(item)">{{ item.applyNo }}</a>
              </div>
            </a-form-model-item>
          </a-col> -->
          <a-col class="gutter-row" :span="24">
            <a-form-model-item :label="$t('all.autotext550')" labelAlign="left" :required="true">
              <a-textarea
                :placeholder="$t('all.autotext1371')"
                style="width: 905px"
                :rows="3"
                v-model="applyReason"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <!-- 费用事项 -->
        <FeeEdit
          @updateFee="updateFee"
          :mattersList="mattersList"
          :mattersItem="mattersItem"
          :researchId="this.centerId"
          :researchDetailId="this.researchDetailId"
          :type="1"
          ref="fee"
        >
        </FeeEdit>
        <!-- 审批预览 -->
        <ApprovePreview
          :offline="offline"
          :nodes="filterFlowNodes"
          @assign="updateAssign"
          :approveUsers="approveUsers"
        />
        <div style="padding-top: 20px">
          <a-button style="margin-left: 10px" :loading="saveDraftLoading" @click="submitDraft">{{ $t('all.autotext321') }}</a-button>
          <a-button
            type="primary"
            style="margin-left: 10px"
            :loading="submitting"
            @click="identityShow"
          > 
            {{ $t('all.autotext218') }} 
          </a-button>
        </div>
      </a-form-model>
    </a-card>
    <DetailView ref="detailView" />
    <a-modal
      :title="$t('all.autotext730')"
      :visible="visibleDraft"
      :closable="false"
      :maskClosable="false"
      :oktext="$t('all.autotext919')"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <p>{{ $t('all.autotext414') }}</p>
    </a-modal>
    <identityCheck ref="identityRef" :content="$t('all.autotext1564')" @ok="submit" />
    <reModal ref="reModal" />
  </div>
</template>
<script>
import moment from 'moment'
import {
  selectResearchCenter,
  selectResearchPerson,
  selectResearchAccount,
  getFlowInfo,
  feeApplyCommitForPI,
  feeApplySaveDraft,
  getDraftDetail,
  getApplySubmitDetail,
  listTeamForResearchNo,
  getOriginFeeApplyInfo,
  preCheckForCommit
} from '@/api/cost/cost'
import { getDepartmentList } from '@/api/common'
import FeeEdit from '../FeeEdit'
import ApprovePreview from '../components/approvePreview.vue'
import identityCheck from '@views/cost-auditing/components/identityCheck'
import reModal from '../components/reModal'
import DetailView from '@/views/cost-auditing/detail.vue'
// import { getApprovalDetail } from '@/api/overview/approval'

export default {
  name: 'AddResearcher',
  components: { FeeEdit, ApprovePreview, identityCheck, reModal, DetailView },
  data () {
    return {
      visibleDraft: false, // 保存草稿弹窗
      draftFlag: false, // 标识是否启用草稿
      proFlowId: null,
      formList: [],
      fileList: [],
      moneyType: 'RMB',
      applyReason: '',
      type: 1,
      totalAmt: 0,
      date: moment().format('YYYY-MM-DD'),
      orgDeptList: [], // 科室
      orgDeptId: null,
      mattersList: [],
      mattersItem: [], // 保存到草稿箱里的费用事项
      loading: true,
      centerList: [],
      centerId: null,
      projectId: '',
      personList: [],
      personId: null,
      accountList: [],
      accountId: null,
      centerName: '',
      orgDeptName: '',
      personName: '',
      accountName: '',
      centerMap: {},
      submitting: false,
      saveDraftLoading: false,
      personMap: {},
      allFlowNodes: [], // 全部审批流程
      filterFlowNodes: [], // 过滤后的审批流程
      assignInfo: {}, // 指定审批人信息
      approveUsers: {}, // 审批人
      isGetFlow: false,
      offline: 1,
      researchDetailId: '',
      OriginFeeApplyInfo: []
    }
  },
  watch: {
    centerId (val) {
      this.getFlow()
    }
  },
  async created () {
    const pd = localStorage.getItem('CURRENT_PROID')
    if (pd) {
      this.projectId = parseInt(pd)
    }
    await this.getCenterList()
    this.getDraft()
    if (this.$route.query.costId) {
      this.getApply()
      this.getOriginInfo()
    }
    // this.getMattersList()
  },
  // 销毁监听事件
  destroyed () {
    this.draftFlag = false
  },
  methods: {
    async getOriginInfo () {
      const res = await getOriginFeeApplyInfo({ costId: this.$route.query.costId })
      this.OriginFeeApplyInfo = res
    },
    handleOk () {
      // 回填数据
      this.draftFlag = true
      this.fillBackData()
      this.visibleDraft = false
    },
    handleCancel () {
      this.draftFlag = false
      this.visibleDraft = false
    },
    getDraft () {
      getDraftDetail({
        proId: this.projectId,
        type: '1'
      }).then(({ haveDraft, feeApplyJson }) => {
        if (haveDraft && !this.$route.query.costId) {
          this.visibleDraft = true
        }
        this.feeApplyJson = JSON.parse(feeApplyJson)
      })
    },
    getApply () {
      getApplySubmitDetail({
        id: this.$route.query.costId
      }).then(res => {
        this.fillBackData1(res)
      })
    },
    /*
    * 回填草稿里数据
    * */
    async fillBackData () {
      const {
        orgId,
        orgDeptName,
        researchDetailNo,
        accountId,
        applyReason,
        fileArray
      } = this.feeApplyJson.feeApply
      if (orgId) {
        this.fillCenterData(orgId)
        if (!this.centerId) return
        await this.getFlow()
        await this.getPersonList()
      }
      if (researchDetailNo) {
        this.personId = researchDetailNo
        await this.getApproveUsers()
      }
      // 中心存在才能再次填充人员和账号，中心都不存在了，人员也无法获取
      if (this.centerName) {
        this.fillPersonNameData(researchDetailNo)
        if (this.personName) {
          await this.getAccountList()
          this.fillAccountData(accountId)
        }
      }
      this.orgDeptName = orgDeptName
      this.applyReason = applyReason

      if (fileArray) {
        this.fileList = JSON.parse(fileArray)
        this.$refs.fee.backFileList(this.fileList)
      }

      if (this.feeApplyJson.feeApplyDetails) {
        const mattersItem = JSON.parse(this.feeApplyJson.feeApplyDetails)
        mattersItem.forEach(item => {
          item.fileList = item.fileArr.map(e => {
            return {
              fileName: e.fileName,
              fileUrl: e.afterUrl || e.originalUrl
            }
          })
          item.fileArr = JSON.stringify(item.fileArr)
        })
        this.fillMatterItem(mattersItem)
      }
    },
    fillMatterItem (list) {
      const availableItem = list.filter(e => {
        return this.mattersList.some(item => item.id === e.proFlowFeeCategoryId)
      })
      this.mattersItem = availableItem.length ? availableItem : list
    },
    /*
    * 回填草稿里数据-- 驳回数据
    * */
    async fillBackData1 (data) {
      const {
        orgId,
        researchDetailNo,
        accountId,
        applyReason
      } = data
      if (orgId) {
        this.fillCenterData(orgId)
        if (!this.centerId) return
        await this.getFlow()
        await this.getPersonList()
      }
      if (researchDetailNo) {
        this.personId = researchDetailNo
        await this.getApproveUsers()
      }
      // 中心存在才能再次填充人员和账号，中心都不存在了，人员也无法获取
      if (this.centerName) {
        this.fillPersonNameData(researchDetailNo)
        if (this.personName) {
          await this.getAccountList()
          this.fillAccountData(accountId)
        }
      }

      this.applyReason = applyReason

      if (data.fileArray) {
        this.fileList = JSON.parse(data.fileArray)
        this.$refs.fee.backFileList(this.fileList)
      }

      if (data.list) {
        this.fillMatterItem(data.list)
      }
    },
    checkDataExistsInList (id, list, prop) {
      return list.some(e => e[prop] === id)
    },
    fillCenterData (orgId) {
      if (this.checkDataExistsInList(orgId, this.centerList, 'id')) {
        this.centerName = orgId
        this.centerId = orgId
      }
    },
    fillPersonNameData (researchDetailNo) {
      if (this.checkDataExistsInList(researchDetailNo, this.personList, 'researchNo')) {
        this.personName = researchDetailNo
      }
    },
    fillAccountData (accountId) {
      if (this.checkDataExistsInList(accountId, this.accountList, 'id')) {
        this.accountId = accountId
      }
    },
    filterOption (input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      )
    },
    updateFee (val, totalAmt, fileList) {
      this.formList = val
      this.fileList = fileList
      this.totalAmt = totalAmt
      this.updateFlowNodes()
    },
    // 请求中心列表
    getCenterList () {
      selectResearchCenter({ proId: this.projectId })
        .then(res => {
          this.centerList = res
          res.forEach(item => {
            this.centerMap[item.id] = item
          })
        })
        .catch(() => {})
    },
    // 请求科室列表
    getDepartmentList () {
      getDepartmentList({ researchId: this.centerId })
        .then(res => {
          const orgDeptId = this.centerMap[this.centerId] ? this.centerMap[this.centerId].orgDeptId : ''
          this.orgDeptList = res.filter(item => orgDeptId.split(',').indexOf(item.id.toString()) >= 0)
          this.orgDeptList.unshift({ id: 19961996, name: this.$t('all.autotext600') })
        })
        .catch(() => {})
    },
    // 请求收款人员列表
    getPersonList () {
      const queryObj = {}
      queryObj.proId = this.projectId
      queryObj.orgDeptId = this.orgDeptId
      queryObj.researchId = this.centerName
      return selectResearchPerson({ ...queryObj })
        .then(res => {
          this.personList = res
          res.forEach(item => {
            this.personMap[item.researchNo] = item
          })
        })
        .catch(() => {})
    },
    // 请求收款账户列表
    getAccountList () {
      const queryObj = {}
      queryObj.researchNo = this.personId
      queryObj.proId = this.projectId
      return selectResearchAccount({ ...queryObj })
        .then(res => {
          this.accountList = res
          if (res && res.length > 0) this.accountId = res[0].id
        })
        .catch(() => {})
    },
    // 中心列表下拉改变
    handleCenterChange (value) {
      this.centerId = value
      this.orgDeptName = ''
      this.orgDeptId = null
      this.personId = null
      this.personName = ''
      this.accountId = null
      this.accountName = ''
      this.orgDeptList = []
      this.personList = []
      this.accountList = []
      // this.getDepartmentList()
      this.getPersonList()
    },
    // 科室列表下拉改变
    handleDepartmentChange (value) {
      if (Number(value) === 19961996) {
        this.orgDeptId = null
      } else {
        this.orgDeptId = value
      }
      this.personId = null
      this.personName = ''
      this.accountId = null
      this.accountName = ''
      this.personList = []
      this.accountList = []
      this.getPersonList()
    },
    // 收款人员列表下拉改变
    handlePersonChange (value) {
      const obj = this.personList.find(v => v.researchNo === value)
      this.researchDetailId = obj.id
      this.personId = value
      this.accountId = null
      this.accountName = ''
      this.accountList = []
      this.getAccountList()
      this.getApproveUsers()
    },
    // 账户列表下拉改变
    handleAccountChange (value) {
      this.accountId = value
    },
    // 获取审批人
    async getApproveUsers () {
      const res = await listTeamForResearchNo({
        researchNo: this.personId,
        proId: this.projectId
      })
      this.approveUsers = res
    },
    // 获取审批流
    async getFlow () {
      if (this.isGetFlow) return
      this.isGetFlow = true
      try {
        const res = await getFlowInfo({
          proId: this.projectId,
          researchId: this.centerId,
          type: this.type
        })
        this.offline = res.offline
        // const res = await getFlowInfo({
        //   proId: 30496,
        //   researchId: 30341,
        //   type: this.type
        // })

        let { nodeList, id, feeCategoryList } = res
        feeCategoryList.forEach(i => {
          i.editable = false
          i.fileList = []
          i.amt = i.defaulted ? i.amt : ''
        })
        this.proFlowId = id
        this.mattersList = feeCategoryList
        nodeList.sort((a, b) => parseInt(a.code) - parseInt(b.code))
        this.allFlowNodes = nodeList
        this.filterFlowNodes = nodeList.filter(item => item.actionType !== 2 && !item.applyType)
        if (this.formList.length > 0) {
          this.updateFlowNodes()
        }
      } catch (err) {
        this.allFlowNodes = []
        this.filterFlowNodes = []
      } finally {
        this.isGetFlow = false
      }
    },
    // 更新审批流
    updateFlowNodes () {
      const addApplyTypes = this.formList.map(item => item.applyType)
      this.filterFlowNodes = this.allFlowNodes.filter(item => {
        if (!item.applyType && item.actionType !== 2) {
          return true
        }
        if (!item.applyType) return false
        const itemApplyTypes = item.applyType.split(',')
        return (itemApplyTypes.some(type => addApplyTypes.includes(type)) && item.actionType !== 2)
      })
    },
    // 选择审批人
    updateAssign (info) {
      this.assignInfo = info
    },
    /**
     * 获取脱敏后的文件地址
     * @param item 文件对象
     * @return {*|string}
     */
    // getDesensitizedFileUrl (item) {
    //   if (!item.fileList || !item.fileList.length) return item.fileUrl || ''
    //   if (item.fileList.length === 1) return (item.fileList[0].afterFileUrl || item.fileList[0].fileUrl)
    //   return item.fileList?.reduce((pre, cur) => {
    //     return pre ? pre + ',' + (cur.afterFileUrl || cur.fileUrl) : (cur.afterFileUrl || cur.fileUrl)
    //   }, '')
    // },
    getFileArr (item) {
      if (!Array.isArray(item)) return []
      return item.map(e => ({
        afterUrl: e.afterFileUrl || '',
        originalUrl: e.fileUrl || '',
        fileName: e.fileName,
        type: this.$const.UPLOAD_FILE_TYPE.FEE_DETAIL.value
      }))
    },
    async identityShow () {
      if (!this.centerName || !this.personName || !this.accountId || !this.applyReason) {
        this.$message.error(this.$t('all.autotext381'))
        return false
      }
      if (this.formList.length === 0) {
        this.$message.error(this.$t('all.autotext851'))
        return
      }
      const target = this.formList.find(item => item.editable === true)
      if (target) {
        this.$message.error(this.$t('all.autotext1293'))
        return false
      }
      const applyTypeItem = this.formList.find(item => !item.applyType)
      if (applyTypeItem) {
        this.$message.error(this.$t('all.autotext1471'))
        return
      }
      const amountItem = this.formList.find(item => !item.amount)
      if (amountItem) {
        this.$message.error(this.$t('all.autotext1061'))
        return
      }
      let assignInfoValid = true
      if (this.assignInfo && Object.keys(this.assignInfo).length) {
        assignInfoValid = Object.values(this.assignInfo).every(item => item !== '')
      }
      if (!assignInfoValid) {
        this.$message.error(this.$t('all.autotext270'))
        return false
      }
      const costDetails = []
      for (const k of this.formList) {
        const fee = this.mattersList.find(v => v.id === k.manageCostId || v.id === k.id || v.applyType === k.applyType)
        costDetails.push({
          proFlowFeeCategoryId: k.manageCostId,
          applyType: k.applyType,
          amount: k.amount,
          apv: fee?.apv,
          defaultAmt: k.defaultAmt,
          defaultBool: fee?.defaulted,
          happenDate: k.happenDate,
          supply: k.supply,
          supplyRemark: k.supplyRemark,
          // fileUrl: k.fileUrl.length ? k.fileUrl.join() : ''
          // fileUrl: this.getDesensitizedFileUrl(k),
          fileUrl: k.fileUrl,
          costMin: k.costMin,
          costMax: k.costMax,
          // comment: k.comment,
          fileArr: this.getFileArr(k.fileList)
        })
        if (!k.applyType) {
          this.$message.error(this.$t('all.autotext1471'))
          return
        }
        if (!k.amount) {
          this.$message.error(this.$t('all.autotext1061'))
          return
        }
      }
      const personObj = this.personMap[this.personName]
      let fileHash = []
      this.fileList.forEach(e => {
        if (e.fileHash) fileHash.push(e.fileHash)
      })
      const subData = {
        proFlowId: this.proFlowId,
        proId: this.projectId,
        orgId: this.centerId,
        orgDeptId: this.orgDeptId,
        userNo: this.personId,
        type: this.type,
        bankId: this.accountId,
        moneyType: this.moneyType,
        applyReason: this.applyReason,
        fileArray: JSON.stringify(this.fileList),
        fileHash: fileHash.join(','),
        feeApplyDetails: JSON.stringify(costDetails),
        researchDetailId: personObj.id || '',
        researchDetailNo: personObj.researchNo || '',
        researchDetailName: personObj.name || '',
        assignInfo: JSON.stringify(this.assignInfo),
        originInfo: JSON.stringify(this.OriginFeeApplyInfo)
      }
      const check = await preCheckForCommit(subData)
      if (check.flag) {
        const that = this
        this.$confirm({
          title: this.$t('all.autotext730'),
          content: (h) => {
            return h('div', check.message.map(node => h('p', node)))
          },
          onOk () {
            that.$refs.identityRef.open()
          }
        })
      } else {
        this.$refs.identityRef.open()
      }
    },
    // 提交
    submit () {
      const costDetails = []
      for (const k of this.formList) {
        const fee = this.mattersList.find(v => v.id === k.manageCostId || v.id === k.id || v.applyType === k.applyType)
        costDetails.push({
          proFlowFeeCategoryId: k.manageCostId,
          applyType: k.applyType,
          amount: k.amount,
          apv: fee?.apv,
          defaultAmt: k.defaultAmt,
          defaultBool: fee?.defaulted,
          happenDate: k.happenDate,
          supply: k.supply,
          supplyRemark: k.supplyRemark,
          // fileUrl: k.fileUrl.length ? k.fileUrl.join() : ''
          // fileUrl: this.getDesensitizedFileUrl(k),
          fileUrl: k.fileUrl,
          costMin: k.costMin,
          costMax: k.costMax,
          // comment: k.comment,
          fileArr: this.getFileArr(k.fileList)
        })
      }
      const personObj = this.personMap[this.personName]
      this.submitting = true
      let fileHash = []
      this.fileList.forEach(e => {
        if (e.fileHash) fileHash.push(e.fileHash)
      })
      this.addResearchPoint()
      const subData = {
        proFlowId: this.proFlowId,
        proId: this.projectId,
        orgId: this.centerId,
        orgDeptId: this.orgDeptId,
        userNo: this.personId,
        type: this.type,
        bankId: this.accountId,
        moneyType: this.moneyType,
        applyReason: this.applyReason,
        fileArray: JSON.stringify(this.fileList),
        fileHash: fileHash.join(','),
        feeApplyDetails: JSON.stringify(costDetails),
        researchDetailId: personObj.id || '',
        researchDetailNo: personObj.researchNo || '',
        researchDetailName: personObj.name || '',
        assignInfo: JSON.stringify(this.assignInfo),
        originInfo: JSON.stringify(this.OriginFeeApplyInfo)
      }
      feeApplyCommitForPI(subData)
        .then(res => {
          this.submitting = false
          const { newFeeApply, msg } = res
          if (newFeeApply.duplicateCheck) {
            this.$refs.reModal.open(newFeeApply)
            return
          }
          if (!msg) {
            this.$message.success(this.$t('all.autotext1401'))
          } else {
            this.$message.warning(msg)
          }
          
          // this.$router.go(-1)
          this.$router.push({ name: 'ResearcherList' })
        })
        .catch(() => {
          this.submitting = false
        })
    },

    // 保存草稿
    submitDraft () {
      const costDetails = []
      for (const k of this.formList) {
        const fee = this.mattersList?.find(v => v.id === k.manageCostId || v.proFlowFeeCategoryId === k.manageCostId || v.id === k.proFlowFeeCategoryId)
        costDetails.push({
          proFlowFeeCategoryId: k.manageCostId,
          applyType: k.applyType,
          amount: k.amount,
          apv: fee?.apv,
          defaultAmt: k.defaultAmt,
          defaultBool: fee?.defaulted,
          happenDate: k.happenDate,
          supply: k.supply,
          supplyRemark: k.supplyRemark,
          // fileUrl: k.fileUrl.length ? k.fileUrl.join() : ''
          // fileUrl: this.getDesensitizedFileUrl(k)
          fileUrl: k.fileUrl,
          fileArr: this.getFileArr(k.fileList),
          costMin: k.costMin,
          costMax: k.costMax
          // comment: k.comment
        })
      }
      const personObj = this.personMap[this.personName]
      this.saveDraftLoading = true
      let fileHash = []
      this.fileList.forEach(e => {
        if (e.fileHash) fileHash.push(e.fileHash)
      })
      this.addResearchPoint()
      feeApplySaveDraft({
        proFlowId: this.proFlowId,
        proId: this.projectId,
        orgId: this.centerId,
        orgDeptId: this.orgDeptId,
        userNo: this.personId,
        type: this.type,
        bankId: this.accountId,
        moneyType: this.moneyType,
        applyReason: this.applyReason,
        fileArray: JSON.stringify(this.fileList),
        fileHash: fileHash.join(','),
        feeApplyDetails: JSON.stringify(costDetails),
        researchDetailId: personObj?.id || '',
        researchDetailNo: personObj?.researchNo || '',
        researchDetailName: personObj?.name || '',
        assignInfo: JSON.stringify(this.assignInfo)
      })
        .then(res => {
          this.saveDraftLoading = false
          this.$message.success(this.$t('all.autotext1316'))
          // this.$router.go(-1)
          // this.$router.push({ name: 'CostApply' })
        })
        .catch(() => {
          this.saveDraftLoading = false
        })
    },
    handleOrigin (item) {
      this.$refs.detailView.open(item.costId)
    },
    // 新增研究者费用申请埋点
    addResearchPoint () {}
  }
}
</script>
<style lang="less" scoped>
.gutter-example .ant-row > div {
  background: transparent;
  border: 0;
}
.gutter-box {
  background: #00a0e9;
  padding: 5px 0;
}
</style>
